Class Constraint

java.lang.Object
edu.uky.ai.csp.kr.Constraint
Direct Known Subclasses:
EqualsConstraint, NotEqualsConstraint

public abstract class Constraint
extends java.lang.Object

A constraint specifies requirements that any solution to the problem must meet. This is the abstract superclass of all constraints.

For simplicity, we assume that all constraints are binary.

Constraints are not symmetric. In other words, for two variable V1 and V2 and some relation *, (V1 * V2) does not imply (V2 * V1).

Author:
Stephen G. Ware
  • Field Summary

    Fields 
    Modifier and Type Field Description
    Variable left
    The left hand side of the constraint
    Variable right
    The right hand side of the constraint
  • Constructor Summary

    Constructors 
    Constructor Description
    Constraint​(Variable left, Variable right)
    Constructs a new constraint object.
  • Method Summary

    Modifier and Type Method Description
    protected abstract boolean testValues​(Solution solution, java.lang.Object left, java.lang.Object right)
    A helper method for testing values which is defined for each new kind of constraint.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • left

      public final Variable left
      The left hand side of the constraint
    • right

      public final Variable right
      The right hand side of the constraint
  • Constructor Details

    • Constraint

      public Constraint​(Variable left, Variable right)
      Constructs a new constraint object.
      Parameters:
      left - the left hand side of the constraint
      right - the right hand side of the constraint
  • Method Details

    • testValues

      protected abstract boolean testValues​(Solution solution, java.lang.Object left, java.lang.Object right)
      A helper method for testing values which is defined for each new kind of constraint.
      Parameters:
      solution - the candidate solution, which provides context for the test
      left - the value for the left variable
      right - the value for the right variable
      Returns:
      false if these values would violate the constraint, true otherwise